#include "napi/native_api.h"
#include "plugin_manager.h"
#include "resourceManager/include/resource_manager.h"
#include "player_manager.h"

EXTERN_C_START
static napi_value Init(napi_env env, napi_value exports)
{
    napi_property_descriptor classProp[] = {
        {"swipe", nullptr, PlayerManager::Swipe, nullptr, nullptr, nullptr, napi_default, nullptr},
        {"start", nullptr, PlayerManager::Start, nullptr, nullptr, nullptr, napi_default, nullptr},
        {"pause", nullptr, PlayerManager::Pause, nullptr, nullptr, nullptr, napi_default, nullptr},
        {"kill", nullptr, PlayerManager::Kill, nullptr, nullptr, nullptr, napi_default, nullptr},
        {"resume", nullptr, PlayerManager::Resume, nullptr, nullptr, nullptr, napi_default, nullptr},
        {"seek", nullptr, PlayerManager::Seek, nullptr, nullptr, nullptr, napi_default, nullptr},
        {"getFileList", nullptr, ResourceManager::GetFileList, nullptr, nullptr, nullptr, napi_default, nullptr},
        {"getRawFileContent", nullptr, ResourceManager::GetRawFileContent, nullptr, nullptr, nullptr, napi_default, nullptr},
        {"getRawFileDescriptor", nullptr, ResourceManager::GetRawFileDescriptor, nullptr, nullptr, nullptr, napi_default, nullptr},
        {"isRawDir", nullptr, ResourceManager::IsRawDir, nullptr, nullptr, nullptr, napi_default, nullptr},
        {"setSurfaceId", nullptr, PluginManager::SetSurfaceId, nullptr, nullptr, nullptr, napi_default, nullptr},
        {"changeSurface", nullptr, PluginManager::ChangeSurface, nullptr, nullptr, nullptr, napi_default, nullptr},
        {"destroySurface", nullptr, PluginManager::DestroySurface, nullptr, nullptr, nullptr, napi_default, nullptr},
    };
    
    napi_define_properties(env, exports, sizeof(classProp) / sizeof(classProp[0]), classProp);
    return exports;
}
EXTERN_C_END

static napi_module ShortVideoModule = {
    .nm_version = 1,
    .nm_flags = 0,
    .nm_filename = nullptr,
    .nm_register_func = Init,
    .nm_modname = "shortvideo",
    .nm_priv = ((void *)0),
    .reserved = { 0 },
};

extern "C" __attribute__((constructor)) void RegisterShortVideoModule(void)
{
    napi_module_register(&ShortVideoModule);
}

